package com.lineage.server.serverpackets;

import com.lineage.server.model.Instance.L1PcInstance;
import java.util.ArrayList;
import java.util.Iterator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class S_SkillBuy extends ServerBasePacket {
  private static final Log _log = LogFactory.getLog(S_SkillBuy.class);
  
  private byte[] _byte = null;
  
  public S_SkillBuy(L1PcInstance pc, ArrayList<Integer> newSkillList) {
    try {
      if (newSkillList.size() <= 0) {
        writeC(41);
        writeH(0);
      } else {
        writeC(41);
        writeD(6000);
        writeH(newSkillList.size());
        Iterator<Integer> iterator = newSkillList.iterator();
        while (iterator.hasNext()) {
          Integer integer = iterator.next();
          writeD(integer.intValue());
        } 
      } 
    } catch (Exception e) {
      _log.error(e.getLocalizedMessage(), e);
    } 
  }
  
  public byte[] getContent() {
    if (this._byte == null)
      this._byte = getBytes(); 
    return this._byte;
  }
  
  public String getType() {
    return getClass().getSimpleName();
  }
}
